﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SeaBattle.Domain.Entities;

namespace SeaBattle.UI.Web.Models
{
    public class GamePlayModel
    {
        public Game Game { get; set; }
        public Player User { get; set; }
        public Player Opponent
        {
            get
            {
                return User == Game.Creator ? Game.Opponent : Game.Creator;
            }
        }

        public Field realField { get{ return Game.realField[User]; } }
        public Field virtualField { get { return Game.virtualField[User]; } }
        
        public string CellClass(Field field, int x, int y)
        {
            switch (field.AField[x, y])
            {
                case FieldType.TYPEACSESS:
                    return "acsess";
                case FieldType.TYPENOACSESS:
                    return "noacsess";
                case FieldType.TYPECLOSEDACSESS:
                    return "closedacsess";
                case FieldType.TYPENONE:
                    return "none";
                case FieldType.TYPEHIT:
                    return "hit";
                case FieldType.TYPEMISS:
                    return "miss";
            }
            return "ship";
        }
        public string StepStatus
        {
            get
            {
                if (User == Game.Step)
                    return "Your Step";
                return "Please, wait!";
            }
        }

        public bool isYourStep
        {
            get {
                if (User == Game.Step)
                    return true;
                return false;
            }
        }
    }
}